package com.ruoyi.jiuzai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiuzai.domain.Table12;
import com.ruoyi.jiuzai.service.ITable12Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 救灾物资Controller
 * 
 * @author ruoyi
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/jiuzai/wuzi")
public class Table12Controller extends BaseController
{
    @Autowired
    private ITable12Service table12Service;

    /**
     * 查询救灾物资列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Table12 table12)
    {
        startPage();
        List<Table12> list = table12Service.selectTable12List(table12);
        return getDataTable(list);
    }

    /**
     * 导出救灾物资列表
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:export')")
    @Log(title = "救灾物资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Table12 table12)
    {
        List<Table12> list = table12Service.selectTable12List(table12);
        ExcelUtil<Table12> util = new ExcelUtil<Table12>(Table12.class);
        util.exportExcel(response, list, "救灾物资数据");
    }

    /**
     * 获取救灾物资详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:query')")
    @GetMapping(value = "/{yId}")
    public AjaxResult getInfo(@PathVariable("yId") Long yId)
    {
        return success(table12Service.selectTable12ByYId(yId));
    }

    /**
     * 新增救灾物资
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:add')")
    @Log(title = "救灾物资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Table12 table12)
    {
        return toAjax(table12Service.insertTable12(table12));
    }

    /**
     * 修改救灾物资
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:edit')")
    @Log(title = "救灾物资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Table12 table12)
    {
        return toAjax(table12Service.updateTable12(table12));
    }

    /**
     * 删除救灾物资
     */
    @PreAuthorize("@ss.hasPermi('jiuzai:wuzi:remove')")
    @Log(title = "救灾物资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yIds}")
    public AjaxResult remove(@PathVariable Long[] yIds)
    {
        return toAjax(table12Service.deleteTable12ByYIds(yIds));
    }
}
